package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Assess;
import com.ruoyi.system.service.IAssessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职称申请Controller
 * 
 * @author ruoyi
 * @date 2023-11-13
 */
@RestController
@RequestMapping("/system/assess")
public class AssessController extends BaseController
{
    @Autowired
    private IAssessService assessService;

    /**
     * 查询职称申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:assess:list')")
    @GetMapping("/list")
    public TableDataInfo list(Assess assess)
    {
        startPage();
        List<Assess> list = assessService.selectAssessList(assess);
        return getDataTable(list);
    }

    /**
     * 导出职称申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:assess:export')")
    @Log(title = "职称申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Assess assess)
    {
        List<Assess> list = assessService.selectAssessList(assess);
        ExcelUtil<Assess> util = new ExcelUtil<Assess>(Assess.class);
        util.exportExcel(response, list, "职称申请数据");
    }

    /**
     * 获取职称申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:assess:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assessService.selectAssessById(id));
    }

    /**
     * 新增职称申请
     */
    @PreAuthorize("@ss.hasPermi('system:assess:add')")
    @Log(title = "职称申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Assess assess)
    {
        return toAjax(assessService.insertAssess(assess));
    }

    /**
     * 修改职称申请
     */
    @PreAuthorize("@ss.hasPermi('system:assess:edit')")
    @Log(title = "职称申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Assess assess)
    {
        return toAjax(assessService.updateAssess(assess));
    }

    /**
     * 删除职称申请
     */
    @PreAuthorize("@ss.hasPermi('system:assess:remove')")
    @Log(title = "职称申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assessService.deleteAssessByIds(ids));
    }
}
